laravel 8 delete by id

42

laravel 8 delete by id -

//For a User table, to delete ID 1:

  $user = User::find(1);

  $user->delete();

//OR
  
  User::where('id', 1)->delete();

//OR
  
  User::destroy(1);

//OR
  
  User::destroy([1, 2, 3]);  //Delete id 1, 2 and 3

Comments

Submit
0 Comments